package com.example.ali.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.ali.R;
import com.githang.statusbar.StatusBarCompat;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * A login screen that offers login via email/password.
 */
public class LoginActivity extends AppCompatActivity {

    @BindView(R.id.go_index)
    ImageView goIndex;
    @BindView(R.id.goregister)
    TextView goregister;
    @BindView(R.id.username)
    EditText username;
    @BindView(R.id.userpssword)
    EditText userpssword;
    @BindView(R.id.login_but)
    Button loginBut;
    @BindView(R.id.forgetpassword)
    TextView forgetpassword;
    @BindView(R.id.weixin)
    LinearLayout weixin;
    @BindView(R.id.imageView)
    ImageView imageView;
    @BindView(R.id.QQ)
    LinearLayout QQ;
    @BindView(R.id.weibo)
    LinearLayout weibo;
    public Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this);
        StatusBarCompat.setStatusBarColor(this, ContextCompat.getColor(this, R.color.colorstatus));
    }

    @OnClick({R.id.go_index, R.id.goregister, R.id.username, R.id.userpssword, R.id.login_but, R.id.forgetpassword, R.id.weixin, R.id.imageView, R.id.QQ, R.id.weibo})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.go_index:
                intent = new Intent(this, MainActivity.class);
                startActivity(intent);

                break;
            case R.id.goregister:
                intent = new Intent(this, RegisterActivity.class);
                startActivity(intent);
                break;
            case R.id.username:
                break;
            case R.id.userpssword:
                break;
            case R.id.login_but:
                if (username.getText().length() != 11 || userpssword.getText().length() <= 5) {
                    if (username.getText().length() != 11) {
                        Toast.makeText(this, "账号不符合规范", Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(this, "密码位数不够", Toast.LENGTH_SHORT).show();
                    }
                } else {
                }
                break;
            case R.id.forgetpassword:
                break;
            case R.id.weixin:
                break;
            case R.id.imageView:
                break;
            case R.id.QQ:
                break;
            case R.id.weibo:
                break;
        }
    }
}

